{% extends "base_index.html" %}
{% load i18n %}
{% load lp_extras %}
{% block content %}

<div id="leftside">
<div id="about">
    <h3>{% trans "About" %}</h3>
    <p>
    {% trans "This web application is intended for solving linear programming problems" %}<a href="{% url lp.lpx.views.documentation LANGUAGE_CODE %}">...</a>
    </p>
    <p class="images">
    <img src="{{ MEDIA_URL }}/img/gnu-head.png" alt="GLPK" />
    <img src="{{ MEDIA_URL }}/img/python.png" alt="python powered" />
    <img src="{{ MEDIA_URL }}/img/vim.png" alt="created with vim" />
    <img src="{{ MEDIA_URL }}/img/django.gif" alt="django project" />
    </p>
</div>
<div id="news">
    <h3>{% trans "Solver" %}</h3>
    <p>{% trans "The GLPK (GNU Linear Programming Kit) package is intended for solving large-scale linear programming (LP), mixed integer programming (MIP), and other related problems. It is a set of routines written in ANSI C and organized in the form of a callable library." %}</p>
</div>
</div>

<div id="main">
    <h3>{% trans "Welcome" %}</h3>
    <p>{% trans "The procedure consist of 3 steps:" %}</p>
    <ol id="mainlist">
    <li>{% trans "basic setup" %}</li>
    <li>{% trans "LP problem" %}</li>
    <li>{% trans "solver setup" %}</li>
    </ol>
    <div class="buttons"><input type="submit" value="{% trans "New project" %}"/></div>
    <div id="userinfo">{% if anonymous %}{% trans "You have to create a project first, or you can " %}<a href=""><a href="{% url lp.lpx.views.settings "login" %}">{% trans "login" %}</a>{% trans " to reach your recent projects." %}{% else %}
    {% if user.is_active %}{% trans "You are logged in as" %} <a href="{% url lp.lpx.views.settings "user" %}">{{ user }}</a>.{% else %}{% trans "You are logged in as an autogenerated user. Please configure your " %}<a href="{% url lp.lpx.views.settings "user" %}">{% trans "profile" %}</a>.{% endif %}
    {% endif %}</div>
    <div id="version">{% trans "Version" %} {{ LP.version }} (Subversion {% trans "Revision" %} r{{ LP.revision }})</div>
</div>

{% if projects %}
<div id="projects">
    <h3>{% trans "Your recent projects" %}</h3>
    {% if projects %}
    <table id="projectstable">
    <tr><th>#</th><th class="project">{% trans "Project" %}</th><th>{% trans "Date / Info" %}</th></tr>
    {% for pro in projects %}
	<tr>
	<td>{{ forloop.counter }}.</td>
	<td><a href="{% url lp.lpx.views.step1 pro.id %}">{{ pro.proname }}</a>
	[{% if pro.project_data.solution %}<a name="qlink" class="p{{ forloop.counter }}" href="{% url lp.lpx.views.solution pro.id %}">s</a>{% else %}s{% endif %}]
	[<a name="qlink" class="p{{ forloop.counter }}" href="{% url lp.lpx.views.delete pro.id %}">x</a>]
	</td>
	<td id="td_p{{ forloop.counter }}">{{ pro.changed|date:"j.n.y H:i" }}</td>
	</tr>
    {% endfor %}
    </table>
    {% else %}
    {% trans "No projects yet." %}
    {% endif %}
    {% Paginator %}
</div>
{% else %}
<div id="noprojects">
</div>
{% endif %}

<script type="text/javascript">
var qLink = document.getElementsByName("qlink");
var gData = null;
var gCell = null;

function hide_info(e) {
    document.getElementById(gCell).innerHTML = gData;
}

function show_info(e) {
    var info = null;
    gCell = "td_" + e.target.className;
    gData = document.getElementById(gCell).innerHTML;

    if (e.target.innerHTML == 'x') {
	info = '{% trans "Delete project" %}';
    }
    else if (e.target.innerHTML == 's') {
	info = '{% trans "View solution" %}';
    }

    document.getElementById(gCell).innerHTML = info;
}

for (var i=0; i < qLink.length; i++) {
    qLink[i].onmouseover = show_info;
    qLink[i].onmouseout = hide_info;
}
</script>
{% endblock %}
